comment


In [1]:
import numpy as np
import urllib
from astropy import units as u
from astropy.coordinates import SkyCoord

In [2]:
# Fetch the catalog list from the Catalina Servers
cat_url = 'http://nesssi.cacr.caltech.edu/DataRelease/CatalinaVars.tbl'
cat_data = urllib.urlopen(cat_url)
catalog = np.genfromtxt(cat_data, dtype=None, names=True)

In [3]:
catalog.dtype


Out[3]:
dtype([('Catalina_Surveys_ID', 'S20'), ('Numerical_ID', '<i8'), ('RA_J2000', 'S11'), ('Dec', 'S11'), ('V_mag', '<f8'), ('Period_days', 'S9'), ('Amplitude', '<f8'), ('Number_Obs', '<i8'), ('Var_Type', '<i8')])

In [4]:
# Get only the Variable Types we are interested in
# See http://nesssi.cacr.caltech.edu/DataRelease/Varcat.html
binary_catalog = catalog[(catalog['Var_Type'] <= 3)]

In [12]:
# The Catalina Server bulk downloader only allows 
for x in xrange(0, len(binary_catalog)):
    if x % 100 == 0:
        try:
            f.close()
        except:
            pass
        filename = 'data/{:06d}.txt'.format(x)
        f = open(filename, 'w')
    
    data = binary_catalog[x]
    
    name = data['Catalina_Surveys_ID']
    ra = data['RA_J2000']
    dec = data['Dec']
    
    ra = "{}h{}m{}s".format(*ra.split(':'))
    dec = "{}d{}m{}s".format(*dec.split(':'))    
    
    c = SkyCoord(ra, dec, 'icrs')
    
    f.write("{}\t{:3.3f}\t{:3.3f}\n".format(name, c.ra.deg, c.dec.deg))